草庐IT

java - 将 TypeScript 转换为 Java

全部标签

javascript - 如何转换 10 :09:00 GMT+0000 to IST in javascript?

我正在开发网络应用程序,因为我们正在使用CK编辑器日历。我在其中执行以下代码以获取Date&Time..代码:varstrDate=newDate(event.start);varendDate=newDate(event.end);vartitle='Event:'+event.title+'From:'+event.start.toLocaleString()+'To:'+event.end.toLocaleString()+'By:';输出:FriFeb13201510:37:00GMT+0000To:FriFeb13201510:37:00GMT+0000预期输出:在上面的输出

javascript - 避免使用 svg 图像进行光栅化,以便在 Firefox 中进行转换

我想申请matrixtransformsvg.Here'safiddle.在Firefox上,它看起来像这样:由于我的View框,它看起来像是在转换之前将其光栅化为10x10位图。我怎样才能避免这种情况?在我看来,我可以尝试找到一种方法来强制Firefox不进行光栅化,或者使用某种形式的嵌入。(??iframe?出于某种原因,我认为这些都是不好的做法。)我正在使用JavaScript动态加载这些SVG。那我该怎么做呢?PS:如果有办法用svg.js,这就是我现在正在使用的,但我非常愿意使用Vanilla来让它工作。编辑:FWIW,显然它已在每晚的Firefox中修复,但我现在仍然想要一

javascript - es6 模块到 commonjs,在 node harmony 标志下使用 typescript

我在--harmony标志下使用带有Node的TypeScript(1.6),所以我想将es6模块语法转换为commonjs。据我所知,我无法使用TypeScript1.6执行此操作。如果我将目标设置为es6,并将模块设置为commonjs,我会收到TypeScript错误-Cannotcompilemodulesinto'commonjs','amd','system'or'umd'whentargeting'ES6'orhigher.为什么TypeScript不能编译成带有ES6目标的commonjs?我想很多人都想这样做,因为Node还不支持ES6模块。我原以为新的moduleR

javascript - TypeScript 处理接口(interface)和类中多余属性的方式不同

我最近在TypeScript中偶然发现了这种奇怪的(imo)行为。在编译期间,只有当预期变量的类型是接口(interface)且接口(interface)没有必填字段时,它才会提示过多的属性。链接到TypeScriptPlayground#1:http://goo.gl/rnsLjdinterfaceIAnimal{name?:string;}classAnimalimplementsIAnimal{}varx:IAnimal={bar:true};//Objectliteralmayonlyspecifyknownproperties,and'bar'doesnotexistinty

javascript - 使用类将 JSON 对象转换为 typescript 类型变量的正确方法?

这是我正在尝试做的一个更简单的例子:exportclassPerson{id:Number;name:String;}exportclassPersonForm{//Thisline:default:Person={name:"Guy"};//Givesthefollowingerror://Error:(25,5)TS2322:Type'{name:string;}'isnotassignabletotype'Person'.//Property'id'ismissingintype'{name:string;}'.//Itried{name:"Guy"}butitgivesthes

Javascript 将 blob 转换为字符串并返回

我可以使用FileReader将blob转换为字符串,但我想将其转换回来:varreader=newwindow.FileReader();reader.readAsDataURL(blob);reader.onloadend=function(){base64data=reader.result;varblobToSend=base64data.substr(base64data.indexOf(',')+1);rtcMultiConnection.send({"command":{"recording":blobToSend,"type":blob.type,"size":blob

javascript - 在 typescript 中获取函数名称

我正在寻找一种方法来获取传入参数的函数名称console.clear();classA{test(){}testCall(fnc:Function){console.log(fnc.name);//iwantitdisplaytestherenotemptyconsole.log(fnc);}}vara=newA();a.testCall(a.test);你可以在jsbin中查看http://jsbin.com/loluhu/edit?js,console 最佳答案 我发现这是typescript中的一个错误你可以在这里找到解决方案

javascript - 为什么我的转换 : translateY flicker in Chrome?

我有一个简单的多列布局;我正在尝试使用translateY在:hover上提升一个元素。它会导致闪烁(在Chrome57上测试过)。我该如何解决这个问题?"usestrict";$(function(){var$target=$('.wall');functiongetImageUrl(id){varwidth=500;varheight=250+Math.floor(Math.random()*150);return"https://unsplash.it/"+width+"/"+height+"?image="+id;}functionaddElement(element){var

javascript - TypeScript 可更新和枚举引用

我有一个用JavaScript编写的外部SDK,我正在使用它。这些模块之一,Blob是可更新的,但也公开了一个枚举FooEnum(成员Bar和Baz).在JavaScript中使用此SDK的代码如下:constblobInstance=newSdk.Blob();constfooType=Sdk.Blob.FooEnum.Baz;我现在正在尝试编写一个接口(interface),我可以将此SDK转换到该接口(interface),以提供一些类型安全性。这是我到目前为止所得到的:interfaceBlobInterface{}enumFoo{Bar,Baz}interfaceSdk{Bl

javascript - 如何在 Vue.js - Nuxt - TypeScript 应用程序中访问路由参数?

我正在构建一个基于NuxtTypeScriptStarter的网站模板。我在我的页面文件夹中创建了一个动态路由的页面_id.vue,我想在我的TS类中访问该id属性。我可以通过编写{{$route.params.id}}在我的模板中访问它,但是当我尝试在类中引用$route时,我得到一个错误:errorTS2304:Cannotfindname'$route'. 最佳答案 作为一个简单的解决方案,尝试从vue-router导入路由,如下所示:importComponentfrom"vue-class-component"import